cmake_minimum_required(VERSION 3.20)

project(
    qrender
    LANGUAGES CXX C
)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt5 COMPONENTS Widgets REQUIRED)

CPMAddPackage(lib3ds
    NAME lib3ds
    GIT_REPOSITORY "https://gitee.com/ls56647426/lib3ds.git"
    GIT_TAG lib3ds-1.3.0
    DOWNLOAD_ONLY YES
    )
if(NOT TARGET lib3ds)
    file(GLOB lib3ds_sources ${lib3ds_SOURCE_DIR}/lib3ds/*.c)
    add_library(lib3ds STATIC ${lib3ds_sources})
    target_include_directories(lib3ds PUBLIC ${lib3ds_SOURCE_DIR}/)
    set_property(TARGET lib3ds PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()

set(_srcs
    src/q3ds_renderer.cpp
    src/axis_renderer.cpp
    src/sphere_renderer.cpp
    src/cone_renderer.cpp
    src/line_renderer.cpp
    src/point_cloud_renderer.cpp
    src/box_renderer.cpp
    src/render_view.cpp
    src/render_manager.cpp
    src/q3ds_model.cpp
    src/renderer.cpp
    src/camera.cpp
    src/q3ds_process.cpp
)

set(_headers
    include/qrender/q3ds_renderer.h
    include/qrender/axis_renderer.h
    include/qrender/sphere_renderer.h
    include/qrender/cone_renderer.h
    include/qrender/line_renderer.h
    include/qrender/point_cloud_renderer.h
    include/qrender/box_renderer.h
    include/qrender/render_view.h
    include/qrender/render_manager.h
    include/qrender/q3ds_model.h
    include/qrender/renderer.h
    include/qrender/camera.h
    src/q3ds_process.h
)

set(PROJECT_SOURCES ${_srcs} ${_headers})

add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES})
target_link_libraries(${PROJECT_NAME} PUBLIC Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} PRIVATE lib3ds)
target_include_directories(${PROJECT_NAME} PUBLIC include)

